package thread;

public class J_ThreadGroup {
    public static void main(String args[]) {
        System.out.println("main start");
        System.out.println("方法 main 所在的线程组含有 " + Thread.activeCount() + " 个线程");
        Thread t = Thread.currentThread();
        ThreadGroup tg = t.getThreadGroup();
        for (; tg != null; tg = tg.getParent()) {
            System.out.println("线程组 " + tg.getName() + " 含有 " + tg.activeCount() + " 个线程"+" MaxPriority:"+tg.getMaxPriority());
            int n = tg.activeCount();
            Thread ts[] = new Thread[n];
            int m = tg.enumerate(ts);
            for (int i = 0; i < m; i++) {
                Thread thread = ts[i];
                System.out.println("第" + i + "个-->" + thread.getName()+" Priority:"+thread.getPriority());
            }
        }
        System.out.println("main end");
    }
}
